<template>
  <div class="container">
    <nuxt-link to="/msbd/classify"> 类别管理 </nuxt-link>
    <nuxt-link to="/users"> 用户管理 </nuxt-link>
    <nuxt-link to="/msbd"> 面试宝典 </nuxt-link>
    <nuxt-link to="/test/111"> 在线考试 </nuxt-link>
    <hr/>
    <ul>
      <li v-for="(item,index) in list" :key="index">{{item.name}}</li>
    </ul>
  </div>
</template>

<script>
// import axios from '@nuxtjs/axios' 不用引入
export default {
  name: "Index",
  data() {
    return {
      a: 20,
      title: "23456"
    };
  },
  // 类似生命周期钩子
  asyncData({ $axios, req, res, error }) {
    // console.log(req,res)//undefined,undefined

    try {
      const { data } = $axios.get(
        "http://locahost:3001/users/user-list?pageSize=10"
      );
      // console.log(data);
      return {
        list: data.data
      };
    } catch (e) {
      error({ mag: "abc" });
    }
  }
};
</script>

<style scoped>
</style>